package com.jn.exam.webSocket.service;

import com.jn.exam.webSocket.component.FanoutSender;
import com.jn.exam.webSocket.entity.MessageResult;
import com.jn.exam.webSocket.service.WebSocketService;
import org.aspectj.bridge.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.websocket.Session;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 江南大学1033190417
 * @date 2022/3/4 20:21
 */
@Service
public class WebSocketService {
    @Autowired
    private FanoutSender fanoutSender;

    public void send(String id, MessageResult messageResult) {
        Map<String, MessageResult> map=new HashMap<>();
        map.put(id,messageResult);
        fanoutSender.sendMessage(map);
    }

    public void senAll( MessageResult messageResult) {
        Map<String,MessageResult> map=new HashMap<>();
        map.put("0",messageResult);
        fanoutSender.sendMessage(map);
    }
}
